// 侧边菜单
import { defineStore } from 'pinia'

export const useUserStore = defineStore('userStore', {
  state: () => {
    return {
      userInfo: {
        token: '',
        memberId: '',
        username: '',
        realname: '',
        department: '',
        position: '',
        tel: '',
        time: '',
        reason: '',
        jurisdiction: '',
        state: '',
        enterpriseName: '',
      },
    }
  },
  getters: {
    fullUserInfo: (state) => {
      return state.userInfo
    },
  },
  actions: {
    updateUserInfo(payload) {
      this.userInfo = {
        ...this.userInfo,
        ...payload,
      }
    },
  },
  // 开启数据缓存
  persist: {
    enabled: true,
    strategies: [
      {
        key: 'USERSTORE',
        storage: localStorage,
      },
    ],
  },
})
